﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpleJson;

namespace Dropbox
{
    public partial class DropBoxQuotaInfo
    {
        public String SharedStorage { get; private set; }
        public String QuotaStorage { get; private set; }
        public String NormalStorage { get; private set; }

        public static DropBoxQuotaInfo Load(string json)
        {
            var result = new DropBoxQuotaInfo();
            JsonObject jsonObj;
            try
            {

                jsonObj = (JsonObject)SimpleJson.SimpleJson.DeserializeObject(json);
            }
            catch (Exception ex)
            {
                return result;
            }
            if (jsonObj.ContainsKey("shared"))
            {
                result.SharedStorage = jsonObj["shared"].ToString();
            }
            if (jsonObj.ContainsKey("quota"))
            {
                result.QuotaStorage = jsonObj["quota"].ToString();
            }
            if (jsonObj.ContainsKey("normal"))
            {
                result.NormalStorage = jsonObj["normal"].ToString();
            }
            return result;
        }
    }
}
